package com.cloud.manager.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cloud.manager.web.domain.Version;
import com.cloud.manager.web.service.VersionService;
import com.cloud.manager.web.mapper.VersionMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author FineEx
 * @description 针对表【tb_version】的数据库操作Service实现
 * @createDate 2021-11-30 18:22:46
 */
@Service
public class VersionServiceImpl extends ServiceImpl<VersionMapper, Version>
        implements VersionService {

    @Resource
    VersionMapper versionMapper;

    @Override
    public List<Version> selectVersionList(Long appId) {
        QueryWrapper<Version> wrapper = new QueryWrapper<>();
        wrapper.eq("appId", appId);
        wrapper.orderByDesc("versionCode", "updateTime");
        List<Version> versions = versionMapper.selectList(wrapper);
        return versions;
    }

    @Override
    public Integer deleteVersion(Long versionId) {
        QueryWrapper<Version> wrapper = new QueryWrapper<>();
        wrapper.eq("id", versionId);
        int id = versionMapper.deleteById(versionId);
        return id;
    }

    @Override
    public Integer addVersion(Version version) {
        int insert = versionMapper.insert(version);
        return insert;
    }
}




